Packet Transmission Method and Apparatus

ABSTRACT

A packet transmission method and an apparatus pertain to the field of network technologies. The method includes obtaining, by a terminal device, a source IP (Internet Protocol) address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is an integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determining that the source IP address in the to-be-transmitted packet is forged, and prohibiting transmitting the to-be-transmitted packet. The application can solve the problem that a virus such as Trojan in the terminal device may be prevented from forging a source IP address of another device to randomly transfer an attack packet in the network to improve network security.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No. 15/585,713, filed on May 3, 2017, which is a continuation of International Patent Application No. PCT/CN2015/076088, filed on Apr. 8, 2015, which claims priority to Chinese Patent Application No. 201410612678.5, filed on Nov. 4, 2014. All of the aforementioned patent applications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to the field of network technologies, and in particular, to a packet transmission method and apparatus.

BACKGROUND

In an application scenario such as a distributed denial-of-service (DDoS) attack, a terminal device carrying a virus such as Trojan transmits an attack packet to a network, and to avoid being tracked, a source Internet Protocol (IP) address in the attack packet is usually forged. A network device usually uses a unicast reverse path forwarding (uRPF) method to filter out the attack packet with the forged source IP address. The network device reads a source IP address in a packet, and determines that the source IP address is forged and discards the packet when a locally stored forwarding information base (FIB) does not include the source IP address.

However, if the source IP address forged by the terminal device is a source IP address of another device, and the forwarding information base includes the source IP address of the another device, the network device cannot filter out the source IP address. As a result, the attack packet can be randomly transferred on the network, which causes relatively low network security.

SUMMARY

To resolve a problem that network security is relatively low because an attack packet with a forged source IP address is randomly transferred on a network, embodiments of the present disclosure provide a packet transmission method and apparatus.

According to a first aspect, a packet transmission method is provided, including obtaining, by a terminal device, a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determining that the source IP address in the to-be-transmitted packet is forged, and prohibiting transmitting the to-be-transmitted packet.

In a first possible implementation manner of the first aspect, the prohibiting transmitting the to-be-transmitted packet includes transmitting a transmission prohibition instruction to a physical coding sublayer (PCS) at a physical layer (PHY), where the transmission prohibition instruction is used to instruct the PCS to prohibit transmitting the to-be-transmitted packet, or prohibiting adding the to-be-transmitted packet to a packet queue, where the packet queue is used to store a packet to be transmitted by the terminal device.

According to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the method further includes transmitting, to a monitoring device, an alarm packet carrying an IP address or a media access control (MAC) address of the terminal device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

According to the first aspect, the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, before the obtaining, by a terminal device, a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, the method further includes setting the terminal device to a filtering state, where the filtering state is used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.

According to a second aspect, a packet transmission apparatus is provided, including an address obtaining module configured to obtain a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer, and a packet processing module configured to when the source IP address, in the to-be-transmitted packet, obtained by the address obtaining module is different from any one of the N IP addresses of the terminal device, determine that the source IP address in the to-be-transmitted packet is forged, and prohibit transmitting the to-be-transmitted packet.

In a first possible implementation manner of the second aspect, the packet processing module is configured to prohibit adding the to-be-transmitted packet to a packet queue, where the packet queue is used to store a packet to be transmitted by the terminal device.

According to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the apparatus further includes a packet transmission module configured to transmit, to a monitoring device, an alarm packet carrying an IP address or a MAC address of the terminal device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

According to the second aspect, the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the apparatus further includes a status setting module configured to set the terminal device to a filtering state, where the filtering state is used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.

According to a third aspect, a packet transmission apparatus is provided, including a PCS and a packet filtering module, where the PCS is connected to the packet filtering module, the packet filtering module is configured to obtain a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determine that the source IP address in the to-be-transmitted packet is forged, generate a transmission prohibition instruction used to prohibit transmitting the to-be-transmitted packet, and transmit the transmission prohibition instruction to the PCS, and the PCS is configured to receive the transmission prohibition instruction, and prohibit transmitting the to-be-transmitted packet according to an instruction of the transmission prohibition instruction.

In a first possible implementation manner of the third aspect, the apparatus further includes a network interface, where the packet filtering module is further configured to generate an alarm packet carrying an IP address or a MAC address of the terminal device, and transmit the alarm packet to the PCS, the PCS is further configured to forward the alarm packet to the network interface, and the network interface is connected to a monitoring device, and configured to forward the alarm packet to the monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

According to the third aspect or the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the apparatus further includes an alarm record register, where the alarm record register is connected to the packet filtering module, the packet filtering module is further configured to generate an interrupt signal, and transmit the interrupt signal to the alarm record register, and the alarm record register is configured to prompt, according to the interrupt signal, an event that the source IP address in the to-be-transmitted packet is forged.

According to the third aspect, the first possible implementation manner of the third aspect, or the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the apparatus further includes a filtering enabling module, where the filtering enabling module is connected to the packet filtering module, and the filtering enabling module is configured to set the packet filtering apparatus to a filtering state, and enable the packet filtering module, where the filtering state is used to instruct the packet filtering apparatus to perform filtering on the source IP address in the to-be-transmitted packet.

The technical solutions provided by the embodiments of the present disclosure include several beneficial effects. A source IP address in a to-be-transmitted packet and N IP addresses of a terminal device are obtained, where N is a positive integer, when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, it is determined that the source IP address in the to-be-transmitted packet is forged, and transmission of the to-be-transmitted packet is prohibited. When it is determined that the source IP address in the to-be-transmitted packet is a forged source IP address, transmission of the to-be-transmitted packet is prohibited, which may prevent the terminal device from being used by a virus such as Trojan to transmit an attack packet, thereby prohibiting the attack packet from entering a network. In this way, the virus such as Trojan in the terminal device can be prevented from forging a source IP address of another device to randomly transfer the attack packet on the network to improve network security.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in embodiments of the present disclosure more clearly, the following briefly describes the accompanying drawings required for describing the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of the present disclosure, and a person of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts.

FIG. 1 is a method flowchart of a packet transmission method according to an embodiment of the present disclosure.

FIG. 2A is a schematic diagram of comparison between a source IP address and an IP address of a terminal device according to an embodiment of the present disclosure.

FIG. 2B is another schematic diagram of comparison between a source IP address and an IP address of a terminal device according to an embodiment of the present disclosure.

FIG. 3 is a structural block diagram of a packet transmission apparatus according to an embodiment of the present disclosure.

FIG. 4 is a structural block diagram of a packet transmission apparatus according to an embodiment of the present disclosure.

FIG. 5 is a structural block diagram of a packet filtering module according to an embodiment of the present disclosure.

FIG. 6 is another structural block diagram of a packet filtering module according to an embodiment of the present disclosure.

FIG. 7 is a structural block diagram of a terminal device according to an embodiment of the present disclosure.

DESCRIPTION OF EMBODIMENTS

To make the objectives, technical solutions, and advantages of the present disclosure clearer, the following further describes the embodiments of the present disclosure in detail with reference to the accompanying drawings.

Referring to FIG. 1, FIG. 1 is a method flowchart of a packet transmission method according to an embodiment of the present disclosure, where the method includes the following steps.

Step 101: A terminal device obtains a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer.

The terminal device includes a device that can access a network, such as a personal computer, a notebook computer, a mobile phone, or a server.

The IP address of the terminal device refers to an IP address that is assigned to the terminal device by the network after the terminal device accesses the network. In this embodiment, the network may assign the N IP addresses to the terminal device, and the terminal device stores the N IP addresses separately, where N is a positive integer.

Before transmitting the to-be-transmitted packet, the terminal device needs to add an IP address of the terminal device to the to-be-transmitted packet such that a device that transfers the to-be-transmitted packet can determine, according to the source IP address in the to-be-transmitted packet, the terminal device that transmits the to-be-transmitted packet. If the to-be-transmitted packet is an attack packet forged by a virus such as Trojan, the source IP address in the to-be-transmitted packet is generally different from the IP addresses of the terminal device to prevent the device that transfers the to-be-transmitted packet from finding the terminal device according to the source IP address in the to-be-transmitted packet. In this embodiment of the present disclosure, to improve network security, before transmitting the to-be-transmitted packet, the terminal device obtains the source IP address in the to-be-transmitted packet, compares the source IP address in the to-be-transmitted packet with the IP addresses of the terminal device, and filters out an attack packet with a forged source IP address, which can prevent the terminal device from being used by the virus such as Trojan to transmit the attack packet.

Performing filtering on the source IP address in the to-be-transmitted packet according to the IP addresses of the terminal device requires occupying some processing resources. Therefore, if the terminal device can determine that the to-be-transmitted packet transmitted by the terminal device is not an attack packet, the terminal device may directly transmit the to-be-transmitted packet without performing filtering on the source IP address to save the processing resources. If the terminal device cannot determine whether the to-be-transmitted packet transmitted by the terminal device is an attack packet, the terminal device needs to perform filtering on the source IP address. In an embodiment, to improve network security, filtering may be performed on source IP addresses in all to-be-transmitted packets.

If filtering needs to be performed on the source IP address, before the terminal device obtains the source IP address in the to-be-transmitted packet and the N IP addresses of the terminal device, the method may further include setting the terminal device to a filtering state, where the filtering state is used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.

The setting the terminal device to a filtering state may be implemented by setting a filtering flag bit for the terminal device. For example, when a value of the filtering flag bit is set to “1”, the terminal device is enabled to perform filtering on the source IP address in the to-be-transmitted packet, that is, the terminal device is set to the filtering state, when the filtering flag bit is set to “0”, the terminal device is disabled from performing filtering on the source IP address in the to-be-transmitted packet, that is, the terminal device is set to a non-filtering state.

The terminal device may be set to the filtering state by default, for example, the numerical value of the filtering flag bit is set to “1” by default. When filtering does not need to be performed on the source IP address, the terminal device is set to the non-filtering state, that is, the filtering flag bit is set to “0”, when filtering needs to be performed on the source IP address, the filtering flag bit does not need to be set. In an embodiment, the terminal device may also be set to the non-filtering state by default, for example, the numerical value of the filtering flag bit is set to “0” by default. When filtering needs to be performed on the source IP address, the terminal device is set to the filtering state, that is, the filtering flag bit is set to “1”, when filtering does not need to be performed on the source IP address, the filtering flag bit does not need to be set. The present disclosure imposes no limitation on a specific implementation manner.

According to the foregoing method for setting the terminal device to the filtering state, the terminal device may detect whether the numerical value of the filtering flag bit indicates the filtering state. If the terminal device detects that the numerical value of the filtering flag bit is, for example, “1”, which indicates the filtering state, it is determined that the terminal device is in the filtering state, and the foregoing step 101 is performed. If the terminal device detects that the numerical value of the filtering flag bit is, for example, “0”, which indicates the non-filtering state, the numerical value of the filtering flag bit is set to a numerical value that indicates the filtering state, for example, “1” to set the terminal device to the filtering state, and then the foregoing step 101 is performed.

Step 102: When the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, the terminal device determines that the source IP address in the to-be-transmitted packet is forged, and prohibits transmitting the to-be-transmitted packet.

The terminal device may detect whether an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet. If an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet, the to-be-transmitted packet is directly transmitted, and a procedure ends. In this case, even if the to-be-transmitted packet is an attack packet, the device that transfers the to-be-transmitted packet can determine the terminal device according to the source IP address in the to-be-transmitted packet, perform security check on the terminal device, and remove a virus such as Trojan when detecting the virus to ensure network security. If no IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet, that is, the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, it is determined that the source IP address in the to-be-transmitted packet is forged, the to-be-transmitted packet may be considered as an attack packet, and transmission of the to-be-transmitted packet is prohibited.

In an embodiment, the detecting whether an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet may include comparing the source IP address in the to-be-transmitted packet with the N IP addresses of the terminal device one by one until comparison with all the N IP addresses of the terminal device is completed, and the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, or an IP address of the terminal device is the same as the source IP address in the to-be-transmitted packet. In an embodiment, the source IP address in the to-be-transmitted packet may be compared with a first IP address of the terminal device bit by bit. When the source IP address in the to-be-transmitted packet is the same as the first IP address of the terminal device in each bit, it is determined that the source IP address in the to-be-transmitted packet is the same as the first IP address of the terminal device, and the comparison process ends. When the source IP address in the to-be-transmitted packet is different from the first IP address of the terminal device in any bit, it is determined that the source IP address in the to-be-transmitted packet is different from the first IP address of the terminal device, and comparison between the source IP address in the to-be-transmitted packet and a second IP address of the terminal device is further performed until comparison with all the N IP addresses of the terminal device is completed, and the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, or an IP address of the terminal device is the same as the source IP address in the to-be-transmitted packet.

Because hardware has a high computing speed and high efficiency, the source IP address in the to-be-transmitted packet may be compared with all the N IP addresses of the terminal device by using the hardware, and whether the source IP address in the to-be-transmitted packet is the same as an IP address in the N IP addresses of the terminal device is determined according to a comparison result. When comparison is performed by using hardware logic, a logical operation may be performed between the source IP address in the to-be-transmitted packet and each of the N IP addresses of the terminal device. In this case, even for an IP address with 32 bits or 128 bits, comparison can be completed within one clock cycle. First, an exclusive OR operation is performed between each IP address of the terminal device and the source IP address in the to-be-transmitted packet to obtain exclusive OR operation results, next, an OR operation is performed on the exclusive OR operation results to obtain OR operation results, then, an AND operation is performed on the N OR operation results corresponding to the N IP addresses of the terminal device, finally, whether an IP address in the N IP addresses of the terminal device is the same as the source IP address is determined according to an AND operation result. For ease of description, in this embodiment of the present disclosure, a four-bit IP address is used as an example to describe a process of comparison, between a source IP address and N IP addresses of a terminal device, implemented by using hardware logic, and reference may be made to FIG. 2A and FIG. 2B.

FIG. 2A shows, assuming that the source IP address in the to-be-transmitted packet is 1001, and the terminal device has four IP addresses, which are respectively 0000, 0001, 0010, and 1001, a process in which the source IP address in the to-be-transmitted packet is compared with the four IP addresses of the terminal device.

An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a first IP address 0000 of the terminal device to obtain an exclusive OR operation result 1001, and an OR operation is performed on 1001 bit by bit to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a second IP address 0001 of the terminal device to obtain an exclusive OR operation result 1000, and an OR operation is performed on 1000 to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a third IP address 0010 of the terminal device to obtain an exclusive OR operation result 1011, and an OR operation is performed on 1011 to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a fourth IP address 1001 of the terminal device to obtain an exclusive OR operation result 0000, and an OR operation is performed on 0000 to obtain an OR operation result “0”. Then, an AND operation is performed on the four obtained OR operation results to obtain an AND operation result “0”, thereby determining that an IP address in the four IP addresses of the terminal device is the same as the source IP address.

FIG. 2B shows, assuming that the source IP address in the to-be-transmitted packet is 1001, and four IP addresses of the terminal device are respectively 0000, 0001, 0010, and 1111, a process in which the source IP address in the to-be-transmitted packet is compared with the four IP addresses of the terminal device.

An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a first IP address 0000 of the terminal device to obtain an exclusive OR operation result 1001, and an OR operation is performed on 1001 to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a second IP address 0001 of the terminal device to obtain an exclusive OR operation result 1000, and an OR operation is performed on 1000 to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a third IP address 0010 of the terminal device to obtain an exclusive OR operation result 1011, and an OR operation is performed on 1011 to obtain an OR operation result “1”. An exclusive OR operation is performed between the source IP address 1001 in the to-be-transmitted packet and a fourth IP address 1111 of the terminal device to obtain an exclusive OR operation result 0110, and an OR operation is performed on 0110 to obtain an OR operation result “1”. Then, an AND operation is performed on the four obtained OR operation results to obtain an AND operation result “1”, thereby determining that no IP address in the four IP addresses of the terminal device is the same as the source IP address, that is, the source IP address in the to-be-transmitted packet is different from any one of the four IP addresses of the terminal device.

That transmission of the to-be-transmitted packet is prohibited may include prohibiting adding the to-be-transmitted packet to a packet queue, where the packet queue is used to store a packet to be transmitted by the terminal device.

Generally, before transmitting the to-be-transmitted packet, the terminal device needs to add the to-be-transmitted packet to the packet queue, and then transmits the to-be-transmitted packet in the packet queue. When determining that the to-be-transmitted packet is an attack packet, the terminal device may directly discard the to-be-transmitted packet without adding the to-be-transmitted packet to the packet queue, thereby preventing the terminal device itself from being used by a virus such as Trojan to transmit the attack packet, and improving network security.

It should be noted that the packet transmission method provided by this embodiment may further include transmitting, to a monitoring device, an alarm packet carrying an IP address and a MAC address of the terminal device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address and the MAC address of the terminal device and monitor the terminal device.

In this embodiment, after determining that the to-be-transmitted packet is an attack packet, the terminal device may further transmit the alarm packet to the monitoring device. After receiving the alarm packet, the monitoring device determines the terminal device according to the IP address or the MAC address carried in the alarm packet and monitors the terminal device. The monitoring device may be a gateway or a device that is provided by a monitoring department. In addition to carrying the IP address of the terminal device and the MAC address of the terminal device, the alarm packet may further carry other information that can be used to identify the terminal device, for example, an international mobile equipment identity (IMEI). This embodiment imposes no limitation on the information carried in the alarm packet.

In an embodiment, the monitoring device may directly perform virus check and remove the attack packet in the terminal device after receiving the alarm packet, or the monitoring device may send a text or voice prompt according to the alarm packet, and monitoring personnel isolates the terminal device according to the prompt and performs virus check and removes on the attack packet to further avoid a security threat brought by the terminal device to a network, improving network security.

It should be noted that the packet transmission method provided by this embodiment may further include prompting an event that the source IP address in the to-be-transmitted packet is forged.

Further, the terminal device may further notify the event that the source IP address in the to-be-transmitted packet is forged to a user that uses the terminal device. For example, the terminal device generates prompt information used to prompt the event that the source IP address in the to-be-transmitted packet is forged, and sends a text or voice prompt according to the prompt information, the user determines, according to the prompt information, that a to-be-transmitted packet (an attack packet) with a forged source IP address exists in the terminal device. In an embodiment, when the terminal device includes a light emitting diode (LED) light, the terminal device may further turn on the LED light, and the user determines, according to the turned-on LED light, that the attack packet with a forged source IP address exists in the terminal device, and may perform processing such as isolation and virus removal on the device.

In conclusion, according to the packet transmission method provided by this embodiment of the present disclosure, a source IP address in a to-be-transmitted packet and N IP addresses of a terminal device are obtained, where N is a positive integer, when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, it is determined that the source IP address in the to-be-transmitted packet is forged, and transmission of the to-be-transmitted packet is prohibited. When it is determined that the source IP address in the to-be-transmitted packet is a forged source IP address, transmission of the to-be-transmitted packet is prohibited, which may prevent the terminal device from being used by a virus such as Trojan to transmit an attack packet, thereby prohibiting the attack packet from entering a network. In this way, the virus such as Trojan in the terminal device can be prevented from forging a source IP address of another device to randomly transfer the attack packet in the network to improve network security.

In addition, an alarm packet carrying an IP address or a MAC address of the terminal device is transmitted to a monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device. The monitoring device may isolate the terminal device and perform virus check and remove the attack packet to further avoid a security threat brought by the terminal device to the network, improving network security.

This embodiment relates to a packet transmission method, which can be implemented as an application program. The application program is installed on a terminal device, and the terminal device executes the application program to implement the packet transmission method shown in FIG. 1 of the present disclosure.

Referring to FIG. 3, FIG. 3 is a structural block diagram of a packet transmission apparatus according to an embodiment of the present disclosure, where the apparatus includes an address obtaining module 310 configured to obtain a source IP address in a to-be-transmitted packet and N IP addresses of a terminal device, where N is a positive integer, and a packet processing module 320 configured to when the source IP address, in the to-be-transmitted packet, obtained by the address obtaining module 310 is different from any one of the N IP addresses of the terminal device, determine that the source IP address in the to-be-transmitted packet is forged, and prohibit transmitting the to-be-transmitted packet.

In an embodiment, the packet processing module 320 is configured to prohibit adding the to-be-transmitted packet to a packet queue, where the packet queue is used to store a packet to be transmitted by the terminal device.

In an embodiment, the packet transmission apparatus provided by this embodiment further includes a packet transmission module configured to transmit, to a monitoring device, an alarm packet carrying an IP address or a MAC address of the terminal device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

In an embodiment, the packet transmission apparatus provided by this embodiment further includes a status setting module configured to set the terminal device to a filtering state, where the filtering state is used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.

In conclusion, the packet transmission apparatus provided by this embodiment of the present disclosure obtains a source IP address in a to-be-transmitted packet and N IP addresses of a terminal device obtained, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determines that the source IP address in the to-be-transmitted packet is forged, and prohibits transmitting the to-be-transmitted packet, which may prevent the terminal device from being used by a virus such as Trojan to transmit an attack packet, thereby prohibiting the attack packet from entering a network. In this way, the virus such as Trojan can be prevented from forging a source IP address of another device to randomly transfer the attack packet on the network to improve network security.

In addition, an alarm packet carrying an IP address or a MAC address of the terminal device is transmitted to a monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device. The monitoring device may isolate the terminal device and perform virus check and remove the attack packet to further avoid a security threat brought by the terminal device to the network, improving network security.

However, an application program is prone to being controlled by some viruses such as Trojan, as a result, security and reliability are relatively low when a packet transmission method is implemented as an application program. Therefore, the packet transmission method may be implemented by using hardware to improve security and reliability of the packet transmission method.

Referring to FIG. 4, FIG. 4 is a structural block diagram of a packet transmission apparatus according to an embodiment of the present disclosure. The apparatus includes a packet filtering module 410, a PCS 420, and a network interface 430, where the PCS 420 is connected to both the packet filtering module 410 and the network interface 430.

The packet filtering module 410 is configured to obtain a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determine that the source IP address in the to-be-transmitted packet is forged, generate a transmission prohibition instruction used to prohibit transmitting the to-be-transmitted packet, and transmit the transmission prohibition instruction to the PCS 420.

The PCS 420 is configured to receive the transmission prohibition instruction, and prohibit transmitting the to-be-transmitted packet according to an instruction of the transmission prohibition instruction. In this case, the network interface 430 cannot receive the to-be-transmitted packet transmitted by the PCS 420, and cannot transmit the to-be-transmitted packet, thereby prohibiting transmitting the to-be-transmitted packet. That is, the network interface 430 prohibits, under the control of the PCS 420, transmitting the to-be-transmitted packet.

The packet filtering module 410 is configured to detect whether an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet.

If the to-be-transmitted packet is an attack packet forged by a virus such as Trojan, the source IP address in the to-be-transmitted packet is generally different from the IP addresses of the terminal device to prevent a device that transfers the to-be-transmitted packet from finding the terminal device according to the source IP address in the to-be-transmitted packet. In this embodiment of the present disclosure, to improve network security, before transmitting the to-be-transmitted packet, the terminal device obtains the source IP address in the to-be-transmitted packet, compares the source IP address in the to-be-transmitted packet with the IP addresses of the terminal device, and filters out an attack packet with a forged source IP address, which can prevent the terminal device from being used by the virus such as Trojan to transmit the attack packet.

The packet filtering module 410 is further configured to if an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet, instruct the PCS 420 to transmit the to-be-transmitted packet. Correspondingly, the PCS 420 is further configured to transmit the to-be-transmitted packet according to an instruction of the packet filtering module 410. In this case, after receiving the to-be-transmitted packet transmitted by the PCS 420, the network interface 430 transmits the to-be-transmitted packet. That is, the network interface 430 transmits the to-be-transmitted packet under the control of the PCS 420.

The network interface 430 may be a media-independent interface (MII), a serial media-independent interface (SMII), a gigabit Ethernet media-independent interface (GMII), a reduced gigabit Ethernet media-independent interface (RGMII), a serial gigabit Ethernet media-independent interface (SGMII), or the like. This embodiment imposes no limitation on the network interface 430.

In this embodiment, that the packet filtering module 410 is implemented at a PHY is used as an example. In an embodiment, that the packet filtering module 410 is disposed between the PCS 420 and a physical medium attachment (PMA) sublayer of the PHY is used as an example. In an embodiment, the packet filtering module may also be implemented at a MAC layer.

In an embodiment, a transmission flag bit is set for the PCS 420, the packet filtering module 410 sets, as a numerical value of the transmission flag bit, a result of comparison between the source IP address in the to-be-transmitted packet and the IP addresses of the terminal device, the PCS 420 determines, according to the numerical value of the transmission flag bit, whether to transmit the to-be-transmitted packet. For example, if a comparison result “1” is set as the numerical value of the transmission flag bit, after learning that the numerical value of the transmission flag bit is “1”, the PCS 420 prohibits transmitting the to-be-transmitted packet, if a comparison result “0” is set as the numerical value of the transmission flag bit, after learning that the numerical value of the transmission flag bit is “0”, the PCS 420 allows transmitting the to-be-transmitted packet.

The PCS 420 may allow, by default, transmitting the to-be-transmitted packet. For example, the numerical value of the transmission flag bit is set to “0” by default, and when transmission of the to-be-transmitted packet needs to be prohibited, the PCS 420 is set to prohibit transmitting the to-be-transmitted packet, that is, a transmission flag bit is set to “1”, when the to-be-transmitted packet needs to be transmitted, the transmission flag bit does not need to be set. In an embodiment, the PCS 420 may prohibit, by default, transmitting the to-be-transmitted packet. For example, the numerical value of the transmission flag bit is set to “1” by default, and when transmission of the to-be-transmitted packet needs to be allowed, the PCS 420 is set to allow transmitting the to-be-transmitted packet, that is, the transmission flag bit is set to “0”, when transmission of the to-be-transmitted packet needs to be prohibited, the transmission flag bit does not need to be set. The present disclosure imposes no limitation on a specific implementation manner.

In this embodiment, after the transmission flag bit for the PCS 420 is set, the transmission flag bit may be further restored to a default value after a predetermined period of time according to a predetermined policy. For example, the numerical value of the transmission flag bit is set to “0” by default, and after the numerical value of the transmission flag bit for the PCS 420 is set to “1”, the numerical value of the transmission flag bit may be further restored to the default value “0” after a predetermined period of time such that the PCS 420 can transmit another to-be-transmitted packet, where the predetermined period of time is used to prohibit the PCS 420 from transmitting some or all of to-be-transmitted packets.

When filtering is being performed on the source IP address according to the IP addresses of the terminal device, the packet filtering module 410 may perform a logical operation between the source IP address in the to-be-transmitted packet and each of the N IP addresses of the terminal device, and determine, according to an obtained comparison result, whether an IP address in the N IP addresses of the terminal device is the same as the source IP address in the to-be-transmitted packet. Because the packet filtering module 410 can perform a logical operation between the source IP address in the to-be-transmitted packet and each of the N IP addresses of the terminal device, the packet filtering module 410 can obtain, within one clock cycle, a result of comparison between the source IP address in the to-be-transmitted packet and the N IP addresses of the terminal device, which greatly improves comparison efficiency.

In an embodiment, the packet filtering module 410 may perform an exclusive OR operation between the source IP address in the to-be-transmitted packet and each of the N IP addresses of the terminal device, perform an OR operation on a numerical value of each exclusive OR operation result, and perform an AND operation on N obtained OR operation results to obtain the comparison result. For details, refer to step 102 shown in the method embodiment, FIG. 2A, and FIG. 2B, and details are not repeatedly described herein.

The packet filtering module 410 is further configured to generate an alarm packet carrying an IP address or a MAC address of the terminal device, and transmit the alarm packet to the PCS 420.

The PCS 420 is further configured to forward the alarm packet to the network interface 430.

The network interface 430 is connected to a monitoring device, and configured to forward the alarm packet to the monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

The monitoring device may be a gateway or a device that is provided by a monitoring department. In addition to carrying the IP address of the terminal device and the MAC address of the terminal device, the alarm packet may further carry other information that can be used to identify the terminal device, for example, an IMEI. This embodiment imposes no limitation on the information carried in the alarm packet.

In an embodiment, the monitoring device may directly perform virus check and remove the attack packet in the terminal device after receiving the alarm packet, or the monitoring device may add a text or voice prompt to the alarm packet, and monitoring personnel isolates the terminal device according to the prompt and performs virus check and removes the attack packet to further avoid a security threat brought by the terminal device to a network, improving network security.

In an embodiment, the packet transmission apparatus provided by this embodiment further includes an alarm record register, where the alarm record register is connected to the packet filtering module 410.

The packet filtering module 410 is further configured to generate an interrupt signal, and transmit the interrupt signal to the alarm record register.

The alarm record register is configured to prompt, according to the interrupt signal, an event that the source IP address in the to-be-transmitted packet is forged.

In this embodiment, the packet filtering module 410 may further notify to a user that uses the terminal device, by using the alarm record register, the event that the source IP address in the to-be-transmitted packet is forged. For example, after receiving the interrupt signal, the alarm record register instructs the terminal device to generate, according to the interrupt signal, prompt information used to prompt the event that the source IP address in the to-be-transmitted packet is forged, and add a text or voice prompt to the prompt information, the user determines, according to the prompt information, that the attack packet with a forged source IP address exists in the terminal device. In an embodiment, when the terminal device includes an LED light, the alarm record register instructs the terminal device to turn on the LED light, and the user determines, according to the turned-on LED light, that an attack packet with a forged source IP address exists in the terminal device, and may perform processing such as isolation and virus removal on the device.

In an embodiment, the packet transmission apparatus provided by this embodiment further includes a filtering enabling module, where the filtering enabling module is connected to the packet filtering module 410.

The filtering enabling module is configured to set the packet filtering apparatus to a filtering state, and enable the packet filtering module 410, where the filtering state is used to instruct the packet filtering apparatus to perform filtering on the source IP address in the to-be-transmitted packet.

That the packet filtering apparatus is set to the filtering state may be implemented by setting a filtering flag bit for the packet filtering apparatus. For example, when a numerical value of the filtering flag bit is set to “1”, the packet filtering apparatus is enabled to perform filtering on the source IP address in the to-be-transmitted packet, when the filtering flag bit is set to “0”, the packet filtering apparatus is disabled from performing filtering on the source IP address in the to-be-transmitted packet.

The packet filtering apparatus may be set to the filtering state by default, for example, the numerical value of the filtering flag bit is set to “1” by default. When filtering does not need to be performed on the source IP address, the packet filtering apparatus is set to a non-filtering state. In an embodiment, the packet filtering apparatus may be set to a non-filtering state by default, for example, the numerical value of the filtering flag bit is set to “0” by default. When filtering needs to be performed on the source IP address, the packet filtering apparatus is set to a filtering state. The present disclosure imposes no limitation on a specific implementation manner.

According to the foregoing setting method for setting the packet filtering apparatus to the filtering state, the filtering enabling module may detect whether the numerical value of the filtering flag bit indicates the filtering state. If the filtering enabling module detects that the numerical value of the filtering flag bit is, for example, “1”, which indicates the filtering state, it is determined that the packet filtering apparatus is in the filtering state. If the filtering enabling module detects that the numerical value of the filtering flag bit is, for example, “0”, which indicates the non-filtering state, the numerical value of the filtering flag bit is set to a numerical value that indicates the filtering state, for example, “1” to set the packet filtering apparatus to the filtering state.

Referring to a structural block diagram of a packet filtering module shown in FIG. 5, an address obtaining circuit 411, an address comparison circuit 412, a filtering enabling circuit 413, a delay circuit 414, an alarm packet transmission circuit 415, and an alarm record register 416 are included in FIG. 5. The address obtaining circuit 411 is connected to the address comparison circuit 412, the address comparison circuit 412 is connected to both the delay circuit 414 and the alarm record register 416, the filtering enabling circuit 413 is connected to both the delay circuit 414 and the alarm record register 416, and the delay circuit 414 is connected to the alarm packet transmission circuit 415.

The address obtaining circuit 411 obtains a source IP address from a to-be-transmitted packet, obtains, from a terminal device, N IP addresses of the terminal device, and transmits the obtained source IP address and the obtained N IP addresses of the terminal device to the address comparison circuit 412. The address comparison circuit 412 performs logical operations between the source IP address in the to-be-transmitted packet and the N IP addresses of the terminal device to obtain a comparison result. When the packet filtering module 410 is enabled by the filtering enabling circuit 413 to perform filtering on the source IP address, the address comparison circuit 412 is triggered to separately transmit the comparison result to a PCS 420, the delay circuit 414, and the alarm record register 416. After the PCS 420 prohibits transmitting the to-be-transmitted packet according to the comparison result, the delay circuit 414 instructs an alarm packet transmission module 415 to transmit an alarm packet to the PCS 420, and the PCS 420 transmits the alarm packet. The alarm record register 416 prompts, according to the comparison result, the packet filtering module 410 with an event of prohibiting transmitting the to-be-transmitted packet.

When the foregoing circuits are implemented, refer to another structural block diagram of the packet filtering module shown in FIG. 6. The following describes a packet transmission method with reference to an implementation structure of the packet filtering module 410.

After the to-be-transmitted packet is received, a numerical value is read from the filtering enabling circuit 413, where the numerical value is a numerical value of a filtering flag bit. When the read numerical value is “1”, transmission of the to-be-transmitted packet is prohibited. When the read numerical value is “0”, transmission of the to-be-transmitted packet is allowed. When the read numerical value is “1”, and it is determined that the packet filtering module 410 is in a filtering state, the address obtaining circuit 411 reads the source IP address from the to-be-transmitted packet and the N IP addresses of the terminal device, and transmits both the source IP address and the N IP addresses of the terminal device to the address comparison circuit 412. The address comparison circuit 412 compares the source IP address with each of the N IP addresses of the terminal device to obtain the comparison result.

A logic circuit of the address comparison circuit 412 transmits the comparison result to the delay circuit 414, and sets the comparison result as a numerical value of a transmission flag bit for the PCS 420. When the comparison result is “1”, the PCS 420 suspends transmission of the to-be-transmitted packet. When the comparison result is “0”, the PCS 420 normally transmits the to-be-transmitted packet. When the numerical value of the transmission flag bit read by the PCS 420 is “1”, and it is determined that transmission of the to-be-transmitted packet is prohibited, the PCS 420 does not transmit the to-be-transmitted packet. After an interval of a predetermined period of time, the numerical value of the transmission flag bit is changed to “0” such that the PCS 420 can continue to transmit the to-be-transmitted packet. In this case, the delay circuit 414 triggers the alarm packet transmission circuit 415 to transmit the alarm packet to the PCS 420, the PCS 420 transmits the alarm packet to a monitoring device, and the monitoring device monitors the terminal device.

In an embodiment, the logic circuit of the address comparison circuit 412 may further transmit the comparison result to the alarm record register 416. The alarm record register 416 generates an interrupt signal according to the comparison result, and transmits the interrupt signal to the terminal device by using an interrupt request, such as an English Interrupt Request (IRQ), pin, or the alarm record register 416 generates, according to the comparison result, a control signal used to turn on an LED light, and transmits the control signal to the terminal device by using an LED pin, or the alarm record register 416 transmits the comparison result to the terminal device by using a Re_OUT pin.

In conclusion, the packet transmission apparatus provided by this embodiment of the present disclosure obtains a source IP address in a to-be-transmitted packet and N IP addresses of a terminal device obtained, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determines that the source IP address in the to-be-transmitted packet is forged, and prohibits transmitting the to-be-transmitted packet. When it is determined that the source IP address in the to-be-transmitted packet is a forged source IP address, transmission of the to-be-transmitted packet is prohibited, which may prevent the terminal device from being used by a virus such as Trojan to transmit an attack packet, thereby prohibiting the attack packet from entering a network. In this way, the virus such as Trojan in the terminal device can be prevented from forging a source IP address of another device to randomly transfer the attack packet on the network to improve network security.

In addition, an alarm packet carrying an IP address or a MAC address of the terminal device is transmitted to a monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device. The monitoring device may isolate the terminal device and perform virus check and remove the packet to further avoid a security threat brought by the packet to the network, improving network security.

Referring to FIG. 7, FIG. 7 is a structural block diagram of a terminal device according to an embodiment of the present disclosure. The terminal device includes a processor 710, a memory 720, and a network interface 730, where the processor 710, the memory 720, and the network interface 730 are connected to each other by using a bus.

The memory 720 stores a program. In an embodiment, the program may include program code, where the program code includes computer operation instructions. The memory 720 may include a random access memory (RAM), or may further include a non-volatile memory, for example, at least one magnetic disk memory.

The processor 710 executes the program stored in the memory 720 to implement a packet transmission method, where the method includes obtaining a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determining that the source IP address in the to-be-transmitted packet is forged, and prohibiting transmitting the to-be-transmitted packet.

In this way, the network interface 730 prohibits transmitting the to-be-transmitted packet under the control of the processor 710.

The prohibiting transmitting the to-be-transmitted packet includes prohibiting adding the to-be-transmitted packet to a packet queue, where the packet queue is used to store a packet to be transmitted by the terminal device.

The memory 720 may be further configured to store the packet queue.

The method may further include transmitting, to a monitoring device, an alarm packet carrying an IP address or a MAC address of the terminal device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device.

The method may further include prompting an event that the source IP address in the to-be-transmitted packet is forged. For example, text or voice prompt information is generated such that a user determines, according to the prompt information, that an attack packet with a forged source IP address exists in the terminal device. In an embodiment, when the terminal device includes an LED light, the LED light may be turned on such that a user determines, according to the turned-on LED light, that the attack packet with a forged source IP address exists, and may perform processing such as isolation and virus removal on the terminal device.

In an embodiment, before the obtaining a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device, the method further includes setting the terminal device to a filtering state, where the filtering state is used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.

The foregoing processor 710 may be a general purpose processor, including a central processing unit (CPU), a network processor (NP), or the like, or may be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or another programmable logical device, a discrete gate or a transistor logic device, or a discrete hardware component.

In conclusion, the terminal device provided by this embodiment of the present disclosure obtains a source IP address in a to-be-transmitted packet and N IP addresses of the terminal device obtained, where N is a positive integer, and when the source IP address in the to-be-transmitted packet is different from any one of the N IP addresses of the terminal device, determines that the source IP address in the to-be-transmitted packet is forged, prohibits transmitting the to-be-transmitted packet. When it is determined that the source IP address in the to-be-transmitted packet is a forged source IP address, transmission of the to-be-transmitted packet is prohibited, which may prevent the terminal device from being used by a virus such as Trojan to transmit an attack packet, thereby prohibiting the attack packet from entering a network. In this way, the virus such as Trojan in the terminal device can be prevented from forging a source IP address of another device to randomly transfer the attack packet on the network to improve network security.

In addition, an alarm packet carrying an IP address or a MAC address of the terminal device is transmitted to a monitoring device, where the alarm packet is used to instruct the monitoring device to determine the terminal device according to the IP address or the MAC address and monitor the terminal device. The monitoring device may isolate the terminal device and perform virus check and remove the terminal device to further avoid a security threat brought by the terminal device to the network, improving network security.

It should be noted that, when the packet transmission apparatus provided by the foregoing embodiments transmits a packet, the division of the foregoing functional modules is merely used as an example for illustration. In an actual application, the foregoing functions may be allocated to and implemented by different function modules according to a requirement, that is, an inner structure of the packet transmission apparatus is divided into different functional modules to implement all or some of the foregoing functions described above. In addition, the packet transmission apparatus provided by the foregoing embodiments is based on similar concepts as the embodiments illustrating the packet transmission method. For a specific implementation process, refer to the method embodiments, and details are not repeatedly described herein.

The foregoing sequence numbers of the foregoing embodiments of the present disclosure are merely for illustrative purposes, and are not intended to indicate priorities of the embodiments.

A person of ordinary skill in the art may understand that all or some of the steps of the foregoing embodiments may be implemented by hardware or a program instructing related hardware. The program may be stored in a computer-readable storage medium. The storage medium mentioned above may include a read-only memory, a magnetic disk, or an optical disc.

The foregoing descriptions are merely exemplary embodiments of the present disclosure, but are not intended to limit the present disclosure. Any modification, equivalent replacement, and improvement made without departing from the principle of the present disclosure shall fall within the protection scope of the present disclosure. 

1. A method implemented by a terminal device, wherein the method comprises: obtaining a source Internet Protocol (IP) address in a to-be-transmitted packet and N IP addresses of the terminal device, wherein N is a positive integer; and comparing the source IP address with each of the N IP addresses before transmitting the to-be-transmitted packet; and prohibiting transmitting the to-be-transmitted packet in response to the source IP address being different from all of the N IP addresses.
 2. The method of claim 1, wherein comparing the source IP address with each of the N IP addresses comprises: performing an exclusive OR operation on the source IP address and each of the N IP addresses to obtain N exclusive OR operation results; performing an OR operation on each of the N exclusive OR operation results to obtain N OR operation results; and performing an AND operation on the N OR operation results to obtain an AND operation result.
 3. The method of claim 2, further comprising setting a filtering flag bit indicating that filtering should be performed on the source IP address of the to-be-transmitted packet.
 4. The method of claim 2, wherein comparing the source IP address in the to-be-transmitted packet with each of the N IP addresses of the terminal device is performed within one clock cycle.
 5. The method of claim 1, wherein prohibiting transmitting the to-be-transmitted packet comprises transmitting a transmission prohibition instruction to a physical coding sublayer (PCS) at a physical layer (PHY), and wherein the transmission prohibition instruction instructs the PCS to prohibit transmitting the to-be-transmitted packet.
 6. The method of claim 1, wherein prohibiting transmitting the to-be-transmitted packet comprises prohibiting adding the to-be-transmitted packet to a packet queue used to store a packet to be transmitted by the terminal device.
 7. The method of claim 1, further comprising transmitting to a monitoring device, an alarm packet carrying at least one of an IP address or a media access control (MAC) address of the terminal device, wherein the alarm packet instructs the monitoring device to monitor the terminal device.
 8. The method of claim 1, wherein before obtaining the source IP address and the N IP addresses, the method further comprises setting the terminal device to a filtering state used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.
 9. A terminal device comprising: a network interface; and a processor coupled to the network interface and configured to: obtain a source Internet Protocol (IP) address in a to-be-transmitted packet and N IP addresses of the terminal device, wherein N is a positive integer; compare the source IP address with each of the N IP addresses before transmitting the to-be-transmitted packet; determine that the source IP address is forged in response to the source IP address being different from all of the N IP addresses; and prohibit transmitting the to-be-transmitted packet via the network interface when the source IP address is forged.
 10. The terminal device of claim 9, wherein the processor is further configured to: perform an exclusive OR operation on the source IP address and each of the N IP addresses to obtain N exclusive OR operation results; perform an OR operation on each of the N exclusive OR operation results to obtain N OR operation results; and perform an AND operation on the N OR operation results to obtain an AND operation result.
 11. The terminal device of claim 10, wherein the processor is further configured to prohibit adding the to-be-transmitted packet to a packet queue used to store a packet to be transmitted by the terminal device.
 12. The terminal device of claim 10, wherein the network interface is configured to transmit, to a monitoring device, an alarm packet carrying at least one of an IP address or a media access control (MAC) address of the terminal device, wherein the alarm packet instructs the monitoring device to monitor the terminal device.
 13. The terminal device of claim 10, wherein the processor is further configured to set the terminal device to a filtering state used to instruct the terminal device to perform filtering on the source IP address in the to-be-transmitted packet.
 14. A packet transmission apparatus comprising: a network interface; and a processor coupled to the network interface and configured to: obtain a source Internet Protocol (IP) address in a to-be-transmitted packet and N IP addresses of a terminal device, wherein N is a positive integer; compare the source IP address with each of the N IP addresses before transmitting the to-be-transmitted packet; determine that the source IP address is forged when the source IP address is different from all of the N IP addresses; and prohibit transmitting the to-be-transmitted packet via the network interface when the source IP address is forged.
 15. The apparatus of claim 14, wherein the processor is further configured to: perform an exclusive OR operation on the source IP address and each of the N IP addresses to obtain N exclusive OR operation results; perform an OR operation on each of the N exclusive OR operation results to obtain N OR operation results; and perform an AND operation on the N OR operation results to obtain an AND operation result.
 16. The apparatus of claim 15, wherein the processor is further configured to set the packet transmission apparatus to a filtering state used to instruct the packet transmission apparatus to perform filtering on the source IP address in the to-be-transmitted packet.
 17. The apparatus of claim 15, wherein the processor is further configured to prompt, according to the AND operation result, an event of prohibiting transmitting the to-be-transmitted packet.
 18. The apparatus of claim 15, wherein the source IP address is compared with each of the N IP addresses within one clock cycle.
 19. The apparatus of claim 14, wherein the processor is further configured to generate an alarm packet carrying at least one of an IP address or a media access control (MAC) address of the terminal device, and wherein the alarm packet is used to instruct a monitoring device to: identify the terminal device according to the at least one of the IP address or the MAC address; and monitor the terminal device.
 20. The apparatus of claim 14, wherein the processor is further configured to: generate an interrupt signal; and prompt, according to the interrupt signal, an event that the source IP address in the to-be-transmitted packet is forged. 